07 Jan 2021

What is git?

“You use Git to take snapshots of all the files in a folder.”

Alice Bartlett


Snapshots in time

Snapshots in time

Three key concepts


  • Repository - your project folder
  • Commit - a snapshot of your folder
  • Branch - a working version of your folder

Three key concepts


  • Repository - your project folder
  • Commit - a snapshot of your folder
    • We use push to send the snapshots online
    • And pull to retrieve an updated snapshot
  • Branch - a working version of your folder

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Work git!

Installing git


  • For Windows, download the executable here
  • On a mac type git --version in your terminal
  • On linux machines type sudo apt install git-all in your terminal


Note that you may need admin rights on your computer, without these you’ll need to request an install.

Create a GitHub account


GitHub offers a range of account types. A free account is available for organisations and individuals.

Even if you’re in an institution, create a personal GitHub account to keep track of you own work.

You’ll find more information, and links for creating an account, here.

Create a repository

  • Follow the instructions here to create your first repository

  • Some key files to include:

    README - ideally format this as a markdown md file (more info here and here)

    LICENSE - how you want people to re-use your code (info)

    .gitignore - names of any files in your project you don’t want on GitHub (templates)

Managing your repository in the command line

  • git is traditionally a command line tool
  • Use these commands to navigate between folders in the command line:
    • cd path/to/new/folder/ - use cd to move between folders (remember that “..” means go back one folder)
    • ls - to list the files and folders in your current folder (dir in Windows)
  • Here’s some more help for Windows, mac, and linux users
  • Once you’re happy with the above commands, here are some screenshots to illustrate using the command line to setup git

git the most out of GitHub


  • Manage your work on a project using the Projects tab
  • Track your tasks using issues
  • Use your README to describe your project (more info here and here)
  • Document your project using a wiki
  • Host a website on GitHub, check out these jekyl themes

Useful resources

  • Introduction to GitHub presentation (slides and video)
  • All you need to know about GitHub in their help pages
  • A game to help us think about git branches (here)
  • ONS GitHub introductory course (here)
  • Tutorial about getting started with git in the command line
  • All you need to know about git in the git handbook
  • My own git glossary to remind me of the crucial git commands

git glossary

Command Definition
git status Check current status of local repository - is it up to date?
git branch List existing branches
git branch [branchName] Create new branch
git branch -d [branchName] Delete branch
git checkout [branchName] Switch to branch
git fetch Get latest version references for repository
git checkout -t origin/[branchName] Switch to remote branch (note you’ll need to run git fetch first)
git push --set-upstream origin [branchName] Push a branch online
git add [FileName] Stage file for committing
git commit -m [message] Commit staged changes to GitHub. Always add meaningful message.
git push Push committed changes to GitHub
git pull Pull changes from GitHub to local repository
git rm [fileName] Remove file and record
git mv [fileName] Move file and version history within repository
git reset --hard HEAD^ Remove un-pushed commits